<%@ Language=JScript%>
<%//Server.ScriptTimeout=1500%>
<%
try
{

  var AuthorizeType = "light"

  var url;
  if (AuthorizeType == "classic")
    url = "https://w3s.webmoney.ru/asp/XMLPurses.asp"
  else
    url = "https://w3s.wmtransfer.com/asp/XMLPursesCert.asp"

  var findwmid =  "161045341777"  	//WMId подписавшего запрос
  var reqwmid =   "865637424965" //  wmidcmp WM id :

  var signstr // только для "classic"

  var reqn = (new Date()).valueOf()


  if (AuthorizeType == "classic")
  {
    var planstr = findwmid+reqn

    var reqwmpwd = "11111"
    var reqwmfilename = "c:\\wmkeeperclassickeyfile.kwm"

    var Signer = Server.CreateObject("WMSignerX.Signer")

    Signer.Login = reqwmid
    Signer.Passwd = reqwmpwd
    Signer.KeyFName = reqwmfilename

    signstr = Signer.SignString(planstr)

  }

  var s = '<w3s.request>'
  s += '<reqn>'+reqn+'</reqn>'
  if ('classic' == AuthorizeType)
  {
    s += '<wmid>'+reqwmid+'</wmid>'
    s += '<sign>'+signstr+'</sign>'
  }
  s += '<getpurses>'
  s += '  <wmid>'+findwmid+'</wmid>'
  s += '</getpurses>'
  s += '</w3s.request>'


  //Response.Write(s);
  //Response.End();


 //var xmlhttp = Server.CreateObject("MSXML2.ServerXMLHTTP.4.0");
  var HttpReq = new ActiveXObject("MSXML2.ServerXMLHTTP.4.0");


  if ("light" == AuthorizeType)
  {
   var certSubj="CURRENT_USER\\MY\\WM id : 865637424965";
        //Response.Write(certSubj);
        //Response.End();
   // xmlhttp.setOption("CURLOPT_SSLKEY","C:/Server/www/interface/version/keys/keyfile.key");
   // xmlhttp.setOption("CURLOPT_SSLKEYPASSWD","123");
   // xmlhttp.setOption("CURLOPT_SSLCERT","C:/Server/www/interface/version/keys/WM_crt.pem");
   // xmlhttp.setOption(3,"C:/Server/www/interface/version/keys/wm.p12");


   xmlhttp.setOption(3, certSubj)

  }
  xmlhttp.open("POST", url, false);
  xmlhttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  xmlhttp.send(s);
//  Response.Write ("1");
//  Response.End();

    var texttes = xmlhttp.responseText;

//  Response.Write(texttes) // при отладке можно посмотреть весь ответ

  var xmlres = Server.CreateObject ('Microsoft.XMLDOM');
  xmlres.loadXML(texttes);

  var retcode = -1

  var Node = xmlres.selectSingleNode("w3s.response/retval")
  if (null!=Node)
    retcode = parseInt(Node.text, 10)
  if (0==retcode)
  {
// получилось, выведем все кошельки
    Node = xmlres.selectNodes('w3s.response/purses/purse')
    for (var i=0;i<Node.length;i++)
    {
      Response.Write(Node.item(i).selectSingleNode('pursename').text)
      Response.Write('-' + Node.item(i).selectSingleNode('amount').text+'<br>')
    }
  }
}
catch(e)
{
  Response.Write('error:'+(new Number(e.number)).toString(16)+'<br>\r\n')
  Response.Write('desc:'+e.description+'\r\n')
}
%>